<?php
header('Content-Type:text/html; Charset=UTF-8');

@$login = $_POST['login'];
@$password = $_POST['password'];

if(empty($login)||empty($password)){
	$mes = '登录名和密码都不能为空';
	include 'index.php';
	die;
}

require 'lib/db.php';
@$user = dbSelect('select id,password from user where login=:lgn',array('lgn'=>$login));

if(empty($user)){
	$mes = '登录名不存在';
	include 'index.php';
	die;
}

if($password!=$user['password']){
	$mes = '密码错误';
	include 'index.php';
	die;
}

session_start();
$_SESSION['userID'] = $user['id'];
header('location:main.php');